home *** CD-ROM | disk | FTP | other *** search
- // TILE LAYER v1.0
- // -------------------------------------------------
-
- // Interface objects
- // -------------------------------------------------
-
- #define ASK_SAVE 1
- #define DONT_ASK 0
-
- #define UP_PAN 24
- #define DOWN_PAN 25
- #define RIGHT_PAN 26
- #define LEFT_PAN 27
-
- class hot_area_group;
-
- // --------------------------
- // Class hot_area.
- // An hot_area is simply an area on the screen that
- // "reacts" to mouse button click
- // --------------------------
-
- class hot_area {
-
- friend hot_area_group;
-
- protected:
- hot_area_group *owner;
- unsigned xpos, ypos;
- unsigned xsize, ysize;
-
- public:
- hot_area(unsigned, unsigned, unsigned, unsigned);
- virtual ~hot_area() {};
- virtual void draw();
- virtual int is_mouse_up();
- virtual void on_mouseup() {};
- };
-
- // ---------------------------
- // Class hot_area_group
- // Is used simplify the management of hot_area classes
- // ---------------------------
-
- class hot_area_group {
- hot_area **hot_areas;
-
- public:
- hot_area_group(hot_area **);
- virtual ~hot_area_group();
- virtual void draw();
- virtual int is_mouse_up();
- virtual void on_mouseup() {};
- };
-
- // -------------------------
- // Class command_target
- // Is an object that "reacts" to command
- // generated by buttons
- // -------------------------
-
- class command_target {
-
- public:
- virtual int handle_command(unsigned );
- };
-
- // -------------------------
- // Class control
- // Base class for the button and pan_control classes
- // It implements the reaction to mouse click and the
- // transmission of the generated command to the command_target
- // -------------------------
-
- class control: public hot_area {
- command_target *target;
- protected:
- unsigned command;
-
- public:
- control(unsigned, unsigned, unsigned, unsigned, unsigned, command_target * );
- virtual void pressed();
- virtual void on_mouseup();
- };
-
- // --------------------------
- // Class button
- // A simple child of control base class.
- // Class button is a control with a label and different
- // drawing methods ( draw() and pressed() ). The base mechanism are
- // inherited.
- // --------------------------
-
- class button: public control {
- char *label;
-
- public:
- button(unsigned, unsigned, char *, unsigned, command_target * );
-
- virtual void pressed();
- virtual void draw();
- };
-
- // --------------------------
- // Class pan_control
- // Another child of control base class.
- // Class pan_control is a control with a different
- // drawing methods. You have to specify the direction
- // of the panning control, the proper command will be
- // generated and trasmitted to target.
- // --------------------------
-
- class pan_control: public control {
- unsigned direction;
-
- public:
- pan_control(unsigned, unsigned, command_target *, unsigned);
-
- virtual void pressed();
- virtual void draw();
- };
-
- // ---------------------------
- // Class tile_set
- // One of the most complex class used in this application.
- // It is an hot_area because it reacts to mouse click and a
- // command_target because it respond to commands given by the
- // tile set control buttons. ( See the file TILELAYR.DOC for further
- // informations ).
- // Class tile_set holds all the bitmaps of the tiles, it has methods
- // for drawing tile on screen, for loading a new set.
- // ---------------------------
-
- class tile_set: public hot_area, public command_target {
- friend world_editor;
-
- char *set_name;
- unsigned char tile_x, tile_y;
- char far **tiles_bitmaps;
- unsigned no_of_tiles, cur_tile;
-
- public:
- tile_set(unsigned, unsigned );
- virtual ~tile_set();
- void destroy_tiles();
- int load_set(char *);
- int put_tile(unsigned, unsigned, unsigned);
-
- virtual void draw();
- virtual void on_mouseup();
-
- virtual int handle_command(unsigned );
-
- friend void Drawcursor();
- };
-
- // --------------------------------
- // The function Drawcursor() is a friend
- // of Class tile_set and Class world_editor in order to
- // simplify the drawing of the mouse cursor.
- // See file TILEMAIN.C where the function is implemented.
- // --------------------------------
-
- // --------------------------------
- // Class world_editor
- // Probably the most complex class of this application.
- // Class world_editor reacts to mouse click and commands generated by
- // edit window scroll buttons and menu buttons, see file TILELAYR.DOC
- // for more informations.
- // All the work of the application is done by the methods of this class.
- // --------------------------------
-
- class world_editor: public hot_area, public command_target {
- char far *world;
- unsigned line_length, no_lines;
- unsigned cur_x, cur_y, buffer_offset;
- unsigned char modified;
- tile_set *world_tiles;
-
- public:
- world_editor(tile_set *, unsigned, unsigned );
- virtual ~world_editor();
- int load_tiles();
- int load_world();
- int save_world(unsigned = 0);
- void scroll(unsigned );
- void redim(unsigned= 0, unsigned= 0);
- void show_info();
-
- virtual void draw();
- virtual void Redraw();
- virtual void on_mouseup();
-
- virtual int handle_command(unsigned );
- friend void Drawcursor();
- };
-
- // -------------------------------------------------
-
-